package com.SunSoft.PhoneRemoteControl;

import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.tasogo.comm.AlphaView;
import com.tasogo.comm.a;
import com.tasogo.comm.c;
import com.tasogo.comm.d;
import com.tasogo.comm.f;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Show_Brand_Select extends Activity
  implements a
{
  String[][] a;
  String[][] b;
  e c;
  String d;
  String e;
  boolean f;
  dh g;
  private ListView h;
  private AlphaView i;
  private TextView j;
  private WindowManager k;
  private f l;
  private List m;
  private dl n;
  private HashMap o;
  private dm p;
  private SQLiteDatabase q;
  private Handler r;

  public Show_Brand_Select()
  {
    String[] arrayOfString1 = { "康佳", "长虹", "创维", "海尔", "海信", "TCL", "小米", "乐视", "酷开", "统帅" };
    String[] arrayOfString2 = { "格力", "美的", "海尔", "海信", "长虹", "TCL", "志高", "奥克斯", "科龙", "松下" };
    String[] arrayOfString3 = { "天龙", "漫步者", "哈曼卡顿" };
    String[] arrayOfString4 = { "其它" };
    this.a = new String[][] { { "康佳", "长虹", "创维", "海尔", "海信", "TCL", "三星", "索尼", "夏普" }, arrayOfString1, { "广电", "有线", "卫星", "其它" }, { "小米", "乐视", "天猫", "百度" }, arrayOfString2, { "先科", "索尼", "步步高" }, { "艾美特", "美的", "格力", "长城" }, { "尼康", "佳能" }, arrayOfString3, { "爱普生", "索尼", "宏基", "三星" }, arrayOfString4 };
    arrayOfString1 = new String[] { "Konka", "Changhong", "Skyworth", "Haier", "Hisense", "TCL", "Xiaomi", "LeTV", "Coocaa", "Leader" };
    arrayOfString2 = new String[] { "Brodcast", "Cable", "Satellite", "other" };
    arrayOfString3 = new String[] { "Xiaomi", "LeTV", "Tmall", "Baidu" };
    arrayOfString4 = new String[] { "Gree", "Midea", "Haier", "Hisense", "Changhong", "TCL", "Chigo", "AUX", "Kelon", "Panasonic" };
    String[] arrayOfString5 = { "SAST", "Sony", "BBK" };
    String[] arrayOfString6 = { "Airmate", "Midea", "Gree", "Greatwall" };
    String[] arrayOfString7 = { "Nikon", "Canon" };
    String[] arrayOfString8 = { "Denon", "Edifier", "Harman" };
    String[] arrayOfString9 = { "Epson", "Sony", "Acer", "Samsung" };
    String[] arrayOfString10 = { "other" };
    this.b = new String[][] { { "Konka", "Changhong", "Skyworth", "Haier", "Hisense", "TCL", "Samsung", "Sony", "Sharp" }, arrayOfString1, arrayOfString2, arrayOfString3, arrayOfString4, arrayOfString5, arrayOfString6, arrayOfString7, arrayOfString8, arrayOfString9, arrayOfString10 };
    this.e = MainControl.i;
    this.f = true;
    this.r = new Handler();
  }

  private static String b(String paramString)
  {
    if (paramString == null)
      return "#";
    if (paramString.trim().length() == 0)
      return "#";
    char c1 = paramString.trim().substring(0, 1).charAt(0);
    if (Pattern.compile("^[A-Za-z]+$").matcher(c1).matches())
      return c1.toUpperCase();
    return "#";
  }

  public final void a(String paramString)
  {
    if ((paramString == null) || (paramString.trim().length() <= 0))
      return;
    this.j.setText(paramString);
    this.j.setVisibility(0);
    this.r.removeCallbacks(this.p);
    this.r.postDelayed(this.p, 700L);
    if (this.o.get(paramString) == null)
      return;
    int i1 = ((Integer)this.o.get(paramString)).intValue();
    this.h.setSelection(i1);
  }

  public void onCreate(Bundle paramBundle)
  {
    int i1;
    int i2;
    super.onCreate(paramBundle);
    setContentView(2130903069);
    this.f = Locale.getDefault().getLanguage().toString().equals("zh");
    paramBundle = (TextView)findViewById(2131165185);
    if (this.f)
    {
      paramBundle.setText(MainControl.g + "-" + getString(2131099652));
      this.e = MainControl.i;
      this.d = "brand_ch";
      this.g = new dh(this);
      this.c = new e(getBaseContext());
      this.q = this.c.getWritableDatabase();
      if (!(this.g.a("is_rotray").equals("1")))
        break label575;
      setRequestedOrientation(9);
    }
    while (true)
    {
      while (true)
      {
        ((ImageView)findViewById(2131165348)).setOnClickListener(new dj(this));
        this.m = new ArrayList();
        this.o = new HashMap();
        this.p = new dm(this, 0);
        this.h = ((ListView)findViewById(2131165426));
        this.i = ((AlphaView)findViewById(2131165427));
        this.i.a(this);
        this.h.setOnItemClickListener(new dk(this));
        this.j = ((TextView)LayoutInflater.from(this).inflate(2130903066, null));
        this.j.setVisibility(4);
        paramBundle = new WindowManager.LayoutParams(-2, -2, 2, 24, -3);
        this.k = ((WindowManager)getSystemService("window"));
        this.k.addView(this.j, paramBundle);
        MyApplication.a().a(this);
        i2 = MyApplication.a().m;
        this.m.clear();
        if ((i2 == 3) && (MyApplication.a().p))
          break label834;
        paramBundle = String.valueOf("");
        paramBundle = this.q.rawQuery("select ID,brand_ch,brand_en ,control_type from brand_list where control_type=? and brand_ch<>?  group  by " + this.d, new String[] { String.valueOf(i2), paramBundle });
        i1 = 0;
        if (i1 < this.a[(i2 - 1)].length)
          break label583;
        if (paramBundle.moveToNext())
          break label693;
        paramBundle.close();
        this.l = new f();
        Collections.sort(this.m, this.l);
        if (this.m.size() > 0)
        {
          if (this.n != null)
            break label936;
          this.n = new dl(this);
          this.h.setAdapter(this.n);
        }
        return;
        paramBundle.setText(MainControl.h + "-" + getString(2131099652));
        this.e = MainControl.j;
        this.d = "brand_en";
      }
      label575: setRequestedOrientation(1);
    }
    label583: Object localObject = new c();
    if (this.f)
    {
      ((c)localObject).a(this.a[(i2 - 1)][i1]);
      ((c)localObject).b(this.b[(i2 - 1)][i1]);
    }
    while (true)
    {
      while (true)
      {
        ((c)localObject).c(getString(2131099909));
        this.m.add(localObject);
        i1 += 1;
      }
      ((c)localObject).a(this.b[(i2 - 1)][i1]);
      ((c)localObject).b(this.a[(i2 - 1)][i1]);
    }
    label693: localObject = new c();
    if (this.f)
    {
      ((c)localObject).a(paramBundle.getString(paramBundle.getColumnIndex("brand_ch")));
      ((c)localObject).b(paramBundle.getString(paramBundle.getColumnIndex("brand_en")));
    }
    while (true)
    {
      while (true)
      {
        ((c)localObject).c(b(d.a(paramBundle.getString(paramBundle.getColumnIndex(this.d)))));
        this.m.add(localObject);
      }
      ((c)localObject).a(paramBundle.getString(paramBundle.getColumnIndex("brand_en")));
      ((c)localObject).b(paramBundle.getString(paramBundle.getColumnIndex("brand_ch")));
    }
    label834: paramBundle = this.q.rawQuery("select control_model ,control_type from control_list where control_type=3 and control_model<>''  group by  control_model ", new String[0]);
    while (true)
    {
      while (!(paramBundle.moveToNext()))
        paramBundle.close();
      localObject = paramBundle.getString(paramBundle.getColumnIndex("control_model"));
      c localc = new c();
      localc.a((String)localObject);
      localc.b("");
      localc.c(b(d.a((String)localObject)));
      this.m.add(localc);
    }
    label936: this.n.notifyDataSetChanged();
  }

  protected void onStop()
  {
    try
    {
      this.k.removeViewImmediate(this.j);
      super.onStop();
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }
}